package com.example.blogdevelop.controller;


import com.example.blogdevelop.common.Result;
import com.example.blogdevelop.entity.User;
import com.example.blogdevelop.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequiresAuthentication
    @GetMapping("/index/{id}")
    public Result index(@PathVariable int id) {
        User user = userService.getById(id);
        return Result.success(user);
    }

    @GetMapping("/")


    @PostMapping("/add")
    public Result add(@Validated @RequestBody User user) {

        return Result.success(user);
    }
}
